[#ftl]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>信息修改</title>
<link rel="stylesheet" type="text/css" href="${base}/css/date.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/base.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/form.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/pop.css" />

<script type="text/javascript" src="${base}/commonjs/jquery1.7.2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery-forms.js"></script>
<script type="text/javascript" src="${base}/commonjs/message/message.js"></script>
<script type="text/javascript" src="${base}/commonjs/noty/jquery.noty.packaged.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery-validation/jquery.validate.min.js" ></script>
<script type="text/javascript" src="${base}/commonjs/jquery-validation/localization/messages_zh.js" ></script>
<script type="text/javascript" src="${base}/commonjs/tab/tabs.js"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog6/dialog-plus-min.js"></script>
</head>
<body>
<!-- 主体开始 -->
<div id="msgs">
[@c.showErrors "" /]
</div>
<div class="dataForm">
<div class="eva_content_top">
	<ul id="eva_all">
		<li><a tab="eva_tab1" class="eva_focus" href="javascript:void(0);">基本信息</a></li>
		<li><a tab="eva_tab2" class="white" href="javascript:void(0);">用户角色</a></li>
	</ul>
</div>
    <div id="eva_tab1" class="eva_tab">
		<form id="dataform" action="update" method="post">
			<div class="content mt10">
			    [#if bean?exists]
				<dl>
					<input  id="beanId" name="id"   type="hidden"  value="${bean.id!''}"/>
					<input type="hidden" name="rolesid" id="rolesid">
				<dt><span   class="required">*</span>账号</dt>
				<dd>			
				<input id="beanAccount"  class="required " name="account"   type="text"  value="${bean.account!''}" readonly="readonly"/>
				</dd>
				<dt><span   class="required">*</span>姓名</dt>
				<dd>			
				<input id="beanName"  class="required " name="name"   type="text"  value="${bean.name!''}"/>
				</dd>
	
				<dt>性别</dt>
				<dd >
					[@c.radios id="gender" value='${bean.gender!}'   input_attributes='style="width:20px;"' datas="common.sex" /]
				</dd>
				<dt>备注</dt>
				<dd>
					<textarea rows="3" cols="30" id="description" name="description" >${bean.description!''}</textarea>
				</dd>
				<dl>
				[/#if]
				<div class="clear"></div>
			</div>
			<div class="pop_btn">
				<input type="button" id="butSave" class="btn_1" value="保存"/>
				<input type="button" id="butCancel" class="btn_1" value="取消"/>
		</div>
		</form>
	</div>
	<div id="eva_tab2" class="eva_tab">
				<div class="userole">
				    <div class="mt10"><span   class="required">*</span>用户角色：</div>	
					<dl>			
				   [#if roles??]
					 [#list roles as items]
					  [#if items.id!=1]						   													   
					   [#if bean.rolesList??]
					        <dt><input type="checkbox" id="roles${items.id}}" name="roles" value="${items.id}" [#list bean.rolesList as item] [#if item.id==items.id] checked="checked" [/#if][/#list]/> ${items.name}</dt>					      
					   [#else]
					        <dt><input type="checkbox" id="roles${items.id}}" name="roles" value="${items.id}" /> ${items.name}</dt>					   
					   [/#if]
					 [/#if]  
				   	[/#list]
				   [/#if]
					</dt>					
					<dl>
				</div>			
		</div>
		
</div>
<script type="text/javascript">	
$(document).ready(function(){
		// 保存
		var rolesid = [];
		$("#butSave").click(function(){
		$("input[name='roles']").each(function(){
				if($(this).attr("checked")=="checked"){
					rolesid.push($(this).attr("value"));
				}
			});
			
		var len = $("input[type='checkbox'][name='roles']:checked").length;
		if(len>0){
		$("#rolesid").val(rolesid);
		}
		  $("#dataform").submit(); 
		});
		var v = jQuery("#dataform").validate({
		 submitHandler:function(form){
			$(form).ajaxSubmit({
			    url:"update",
				success: function(data){  
                        noty({
                          text:extendMessages(data).msg.message,
                          layout:"center",
                          timeout:2000,
                          callback:{
                             afterClose:function(){
                                          window.parent.location.reload(); 
                                        }
                           }
                        });
               }
			});	
		 }      
		});
		    
		$("#butCancel").click(function(){
			window.parent.closeArtDialog(); 
		});
		
	});
	$(function() {
		$("#submitRoles").click(function(){	
		$("#eva_all li a").removeClass().addClass("white");
		$("#eva_all li:first").removeClass().addClass("eva_focus");
    $("#eva_tab2").hide();
    $("#eva_tab1").show();
	});	
 });
</script>
</body>
</html>